package cn.famouscat.ex003;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.Button;

public class MainActivity extends ActionBarActivity {

    Button mBtnA;
    Button mBtnB;

    MyView pieView;
    MyViewLine lineView;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mBtnA = (Button) findViewById(R.id.btn_a);
        mBtnB = (Button) findViewById(R.id.btn_b);

        pieView = (MyView) findViewById(R.id.pieView);
        lineView = (MyViewLine) findViewById(R.id.lineView);

        pieView.setData(new int[]{1,3,3,4,8,4});
        lineView.setData(new int[]{1,3,3,4,8,4});

    }




    public void onBtnClick(View v){
        switch (v.getId()){
            case R.id.btn_a:{
                int[] a = new int[5];
                for(int i=0;i<5;i++){
                    int k = (int) ((Math.random())*10);
                    a[i] = k==0?1:k;
                }
                pieView.setData(a);
                lineView.setData(a);
            }break;
            case R.id.btn_b:{

                pieView.smoothScrollTo(-200,-400);
                pieView.smoothScrollTo(0,0);

            }break;
            case R.id.btn_c:{
                getFragmentManager();


            }break;

        }
    }
}
